package healthwatcher.data.gae;

import javax.jdo.PersistenceManager;

import healthwatcher.data.ISpecialityRepository;
import healthwatcher.model.healthguide.MedicalSpeciality;
import lib.exceptions.ObjectAlreadyInsertedException;
import lib.exceptions.ObjectNotFoundException;
import lib.exceptions.ObjectNotValidException;
import lib.exceptions.RepositoryException;
import lib.persistence.IPersistenceMechanism;
import lib.util.IteratorDsk;

public class SpecialityRepositoryGAE implements ISpecialityRepository {

	private IPersistenceMechanism mp;


	public SpecialityRepositoryGAE(IPersistenceMechanism mp) {
		this.mp = mp;
	}
	
	@Override
	public void insert(MedicalSpeciality esp) throws ObjectNotValidException,
			ObjectAlreadyInsertedException, ObjectNotValidException,
			RepositoryException {

			PersistenceManager pm = (PersistenceManager) mp.getCommunicationChannel();
			pm.makePersistent(esp);
			pm.close();
	}

	@Override
	public void update(MedicalSpeciality esp) throws ObjectNotValidException,
			ObjectNotFoundException, ObjectNotValidException,
			RepositoryException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean exists(int num) throws RepositoryException {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void remove(int codigo) throws ObjectNotFoundException,
			RepositoryException {
		
		MedicalSpeciality medicalSpeciality = search(codigo);
		PersistenceManager pm = (PersistenceManager) mp.getCommunicationChannel();
		pm.deletePersistent(medicalSpeciality);
		pm.close();
		
		
	}

	@Override
	public IteratorDsk getSpecialityList() throws ObjectNotFoundException,
			RepositoryException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public MedicalSpeciality search(int codigo) throws ObjectNotFoundException,
			RepositoryException {
		// TODO Auto-generated method stub
		return null;
	}

}
